<?php

class Tyh_Default_Controller extends Tyh_Base_Controller
{
	public function __construct()
	{
		parent::__construct();
		
		$this->action
			->add('init', 'loadDefaultStyles', 5);
	}
	
	public function loadDefaultStyles()
	{
		if( is_admin() )
			return;
		
		$prefix = strtolower( $this->config->get('prefix') ) . '-';
		$template_dir = get_template_directory_uri();
		
		// load up primary stylesheet
		wp_register_style($prefix.'style', get_stylesheet_directory_uri() . '/'.'style.css' , array(), NULL, 'screen');
		wp_enqueue_style($prefix.'style');
		
		// title => folder
		$parent_styles = array(
			'reset' => 'styles',
			'typography' => 'styles',
			'2c-r-fixed' => 'layouts',
			'images' => 'styles',
			'plugins' => 'styles'
		);
		
		foreach( $parent_styles as $style => $src )
		{
			wp_register_style($prefix.$style, $template_dir.'/library/'.$src.'/'.$style.'.css' , array($prefix.'style'), NULL, 'screen');

			wp_enqueue_style($prefix.$style);
		}
		
		// get a unix timestamp to use as version number for tyh-style (see below).
		// this way, the browser always uses a fresh stylesheet, instead of the cached one
		$time = time();
		
		wp_register_style( $prefix.'style', get_stylesheet_directory_uri().'/style.css', array(), $time, 'screen');
		
		wp_enqueue_style($prefix.'style');
	}
}